@{
    Layout = null;

    var dscode = ViewContext.RouteData.Values["id"]?.ToString();
    var uinfo = Netnr.Blog.Web.Apps.LoginService.Get(ViewContext.HttpContext);
}

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>@ViewData["Title"] @GlobalTo.GetValue("Common:EnglishName") Doc</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    @Html.Raw(Netnr.SharedApp.QuoteTo.Html("favicon,blog-seo"))

    <style>
        .hide {
            display: none;
        }

        .github-corner svg {
            width: 80px;
            height: 80px;
        }

        .sidebar ul li p.active > a {
            border-right: 2px solid;
            font-weight: 600;
            color: #42b983;
        }
    </style>
</head>
<body>
    <nav class="app-nav no-badge hide">
        <ul>
            <li>
                @if (uinfo.UserId == 0)
                {
                    <a data-href="/doc/discover" title="Doc">
                        <i class="fa fa-fw fa-lg fa-book text-success"></i>
                    </a>
                }
                else
                {
                    <a data-href="/doc/user/@uinfo.UserId" title="Your doc">
                        <i class="fa fa-fw fa-lg fa-book text-success"></i>
                    </a>
                }
            </li>
            <li>
                <i class="fa fa-fw fa-th-list"></i> 菜单
                <ul>
                    <li>
                        <a data-href="/doc/code/edit/@dscode" title="Add">
                            <i class="fa fa-fw fa-plus"></i> 添加
                        </a>
                    </li>
                    <li>
                        <a data-href="/doc/code/catalog/@dscode" title="Menu">
                            <i class="fa fa-fw fa-folder-open"></i> 目录
                        </a>
                    </li>
                    <li></li>
                    <li>
                        <a data-href="/doc/code/edit/@dscode?dsdid=" title="Edit">
                            <i class="fa fa-fw fa-lg fa-edit"></i> 编辑
                        </a>
                    </li>
                    <li>
                        <a data-href="/doc/code/del/@dscode?dsdid=" title="Delete">
                            <i class="fa fa-fw fa-lg fa-trash"></i> 删除
                        </a>
                    </li>
                    <li></li>
                    <li>
                        <a target="_blank" href="/doc/code/export/@dscode" title="Word">
                            <i class="fa fa-fw fa-lg fa-file-word-o"></i> 导出
                        </a>
                    </li>
                    <li>
                        <a data-href="javascript:window.print()" title="Print">
                            <i class="fa fa-fw fa-lg fa-print"></i> 打印
                        </a>
                    </li>
                </ul>
            </li>
        </ul>
    </nav>

    <div id="app">
        Loading ...
    </div>

    <!--SEO-->
    <div class="hide">
        @Html.Raw(ViewData["DocSeo"])
    </div>

    <script>
        window.$docsify = {
            noEmoji: true,
            auto2top: true,
            loadSidebar: true,
            routerMode: 'history',
            markdown: {
                renderer: {
                    code: function (str, lang) {
                        var ch = [];
                        ch.push("<pre><code>");
                        try {
                            str = hljs.getLanguage(lang)
                                ? hljs.highlight(lang, str).value
                                : hljs.highlightAuto(str).value;
                            ch.push(str);
                        } catch (__) {
                            ch.push(str);
                        }
                        ch.push("</code></pre>");
                        return ch.join('');
                    }
                }
            }
        };

        function get(url, success) {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', url, true);
            xhr.send();
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    success(xhr.responseText)
                }
            };
        }

        get('https://cdn.jsdelivr.net/npm/docsify@4.11.6/lib/themes/vue.css', function (res) {
            var ele = document.createElement("STYLE");
            ele.innerHTML = "*" + res.split(';*')[1];
            document.getElementsByTagName("HEAD")[0].appendChild(ele);

            var nav = document.querySelector(".app-nav");
            nav.className = nav.className.replace("hide", "");
        })

        //菜单点击处理
        document.querySelector(".app-nav").onclick = function (e) {
            e = e || window.event;
            var target = e.target || e.srcElement;

            var alla = this.getElementsByTagName('a');
            for (var i = 0; i < alla.length; i++) {
                var ai = alla[i];
                if (ai.contains(target)) {
                    var ahref = ai.getAttribute('data-href');
                    if (ahref) {
                        var did = location.pathname.split('/')[4];
                        switch (ai.title) {
                            case "Edit":
                                if (did.length == 19) {
                                    location.href = ahref + did;
                                } else {
                                    alert("请选择子页面操作")
                                }
                                break;
                            case "Delete":
                                if (did.length == 19) {
                                    if (confirm("确定删除？")) {
                                        location.href = ahref + did;
                                    }
                                } else {
                                    alert("请选择子页面操作")
                                }
                                break;
                            case "Print":
                                {
                                    if (document.body.className.indexOf("close") == -1) {
                                        document.body.className += " close";
                                    }
                                    location.href = ahref;
                                }
                                break;
                            default:
                                location.href = ahref;
                        }
                    }
                    break;
                }
            }
        }
    </script>

    @Html.Raw(Netnr.SharedApp.QuoteTo.Html("fa.css,netnrmd.css,netnrmd.js,docsify.js"))
</body>
</html>